package ssm.dao;

import org.apache.ibatis.annotations.*;
import ssm.domain.Permission;

import java.util.List;

public interface IPermissionDao {

    @Select("select * from permission where id in (select permissionId from role_permission where roleId = #{roleId})")
    List<Permission> findPermissionByRoleId(String roleId) throws Exception;

    @Select("select * from permission")
    List<Permission> findAll() throws Exception;

    @Insert("insert into permission(id,permissionName,url) values('#3',#{permissionName},#{url})")
    void save(Permission permission);

    @Select("select * from permission where id= #{id} ")
    Permission findById(String id) throws Exception;

    @Delete("delete from role_permission where permissionId =#{id}")
    void deleteFromRole_Permission(String id) throws Exception;

    @Delete("delete from permission where id =#{id}")
    void deleteById(String id) throws Exception;
}
